import { id } from "element-plus/es/locale";
import request from "./request";
export function login(username, password, type) {
    return request({
        url: 'login',
        method: 'post',
        data: {
            username,
            password,
            type
        }
    })
}

export function findAllStudent() {
    return request({
        url: '/student/all',
        method: 'get'
    })
}

export function reegisterStudent(username, password, name, gender, age, type) {
    return request({
        url: '/register',
        method: 'post',
        data: {
            username,
            password,
            name,
            gender,
            age,
            type
        }
    })
}

export function editMessage() {
    return request({
        url: '/student/editMessage',
        method: 'post'
    })
}

export function getGrades(name) {
    return request({
        url: `/student/selfGrade/${name}`,
        method: 'get'
    })
}

export function getLogout() {
    return request({
        url: '/logout',
        method: 'get'
    })
}

export function getStudentGradeById(id) {
    return request({
        url: `/student/studentGrade/${id}`,
        method: 'get',
    })
}

export function getStudentCourseById(id) {
    return request({
        url: `/student/studentCourse/${id}`,
        method: 'get',
    })
}


// teacher专属api
export function getTeacherCourse(id) {
    return request({
        url: `/course/findAllById/${id}`,
        method: 'get'
    })
}

//删除学生

export function deleteStudent(id) {
    return request({
        url: `/student/deleteStudentById/${id}`,
        method: 'get'
    })
}

export function editStudent() {
    return request({
        url: `/student.editStudentById/${id}`,
        method: 'get'
    })
}
//student
export function getMyGradeAndCourse() {
    return request({
        url: '/student/getMySelfStudentAndGrade',
        method: 'get'
    })
}

export function getMySelfIntroduce() {
    return request({
        url: '/student/getMySelfIntroduce',
        method: 'get'
    })
}


export function checkPassword(password) {
    return request({
        url: '/checkPassword',
        method: 'get',
        params:{
            password:password
        }
    })
}

//student修改信息

export function studentSubmit() {
    return request({
        url: '/student/studentSubmit',
        method: 'post'
    })
}


export function searchStudentByName(name) {
    return request({
        url: '/student/searchStudent',
        method: 'post',
        data:{
            name:name
        }
    })
}


export function getTeacherCourseById() {
    return request({
        url: `/teacher/getTeacherCourseById`,
        method: 'get'
    })
}

export function getTeacherStudentById() {
    return request({
        url: `/teacher/getTeacherStudentById`,
        method: 'get'
    })
}
//teacher
export function getTeacherMessage() {

    return request({
        url: '/teacher/getMessage',
        method: 'get'
    })
}

export function updateMessage(password,name,gender,age,username){
    return request({
        url:'/updateMessage',
        method:'post',
        data:{
            password,name,gender,age,username
        }
    })
}

export function getStudentMessage(id){
    return request({
        url:`/student/my/${id}`,
        method:'get'
    })
}


export function updateMessageStudent(s_id,s_age,s_name,s_gender){
    return request({
        url:'student/updateStudent',
        method:'post',
        data:{
          s_id,
          s_age,
          s_name,
          s_gender
        }
    })
}

export function insertStudent(name,username,age,gender,password){
    return request({
        url:'/student/insertStudent',
        method:'post',
        data:{
          name,
          username,
          age,
          gender,
          password
        }
    })
}